<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
    <link href="/res/third/bootstrap3/css/bootstrap-select.css" rel="stylesheet" type="text/css" />
    <link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="panel panel-info panel-content">
    <table class="table table-hover table-bordered table-striped table-condensed">
        <thead>
        <tr>
            [#--[#if order.ifBatchPay?? && order.ifBatchPay == 1]
            <th>批次</th>
            [/#if]--]
            <th>支付时间</th>
            <th>支付金额</th>
            <th>支付凭证</th>
            <th>交易合同</th>
            <th>操作</th>
        </tr>
        </thead>
    [#list list as pay]
        <tr>
            [#--[#if order.ifBatchPay?? && order.ifBatchPay == 1]
            <td>第${pay_index + 1}批</td>
            [/#if]--]
            <td>${pay.payTime?datetime!}</td>
            <td>${pay.totalPrice!}</td>
            <td>
                [#if pay.proveImg?? && pay.proveImg != '']
                    [#list pay.proveImg?split(',') as img]
                        <a target="_blank" href="${img}" data-img="${img}">凭证${img_index + 1}</a>
                        [#if img_has_next]，[/#if]
                    [/#list]
                [/#if]
            </td>
            <td>
                [#if pay.contractFile?? && pay.contractFile != '']
                    [#list pay.contractFile?split(',') as img]
                        <a target="_blank" href="${img}" data-img="${img}">合同${img_index + 1}</a>
                        [#if img_has_next]，[/#if]
                    [/#list]
                [/#if]
            </td>
            <td>
                <button class="btn btn-info btn-xs" onclick="audit('${pay.id!}', true)">通过</button>
                <button class="btn btn-info btn-xs" onclick="audit('${pay.id!}', false)">驳回</button>
            </td>
        </tr>
    [/#list]
    </table>

</div>

<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/bootstrap3/bootstrap.min.js" type="text/javascript"></script>

<script type="text/javascript">
    function audit(payId, pass) {
        if(!pass) {
            layer.prompt({
                title: '请输入拒绝原因',
                formType: 2
            }, function(rejectReason) {
                if($.trim(rejectReason) == '') {
                    alert('请输入拒绝原因');
                    return;
                }
                doAudit(payId, pass, rejectReason);
            });
        } else {
            doAudit(payId, pass, '');
        }
    }
    
    function doAudit(payId, pass, rejectReason) {
        $.ajax({
            url : '/order/audit.do',
            type : 'post',
            dataType : 'json',
            data : {payId : payId, pass : pass, rejectReason : rejectReason},
            beforeSend : function() {
                layer.load(2, {shade: 0.1});
            },
            success : function(data) {
                if(data.success) {
                    layer.alert("操作成功", function() {
                        location.reload();
                    });
                } else {
                    layer.alert(data.msg);
                }
            },
            complete : function() {
                layer.closeAll('loading');
            }
        });
    }
</script>
</body>
</html>